#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn=1010;
int cmp1(int a,int b){
    return a>b;
}
vector<int> father,isRoot;
int findFather(int x){
    int a=x;
    while(x!=father[x]){
        x=father[x];
    }
    while(a!=father[a]){
        int z=a;
        father[z]=x;
        a=father[a];
    }
    return x;
}
void Union(int a, int b){
    int fa=findFather(a);
    int fb=findFather(b);
    if(fa!=fb){
        father[fa]=fb;
    }
}
int main(){
    //freopen("in.txt","r",stdin);
    int N,k,t,cnt=0;
    int course[maxn]={0};
    scanf("%d",&N);
    father.resize(N+1);
    isRoot.resize(N+1);
    for(int i=1;i<=N;i++){
        father[i]=i;
    }
    for(int i=1;i<=N;i++){
        scanf("%d:",&k);
        for(int j=0;j<k;j++){
            scanf("%d",&t);
            if(course[t]==0){
                course[t]=i;
            }
            Union(i,findFather(course[t]));
        }
    }
    for(int i=1;i<=N;i++){
        isRoot[findFather(i)]++;
    }
    for(int i=1;i<=N;i++){
        if(isRoot[i]!=0){cnt++;}
    }
    printf("%d\n",cnt);
    sort(isRoot.begin(),isRoot.end(),cmp1);
    for(int i=0;i<cnt;i++){
        if(i==0){printf("%d",isRoot[i]);}
        else {printf(" %d",isRoot[i]);}
    }
    printf("\n");

}
